<template>
	<div>
		<snowy-form-design hideResetHint :databaseConfig="databaseConfig" :dictData="dictData" />
	</div>
</template>

<script>
	import { setFormDesignConfig } from '@/mini'
	export default {
		name: 'App',
		data() {
			return {
				databaseConfig: [
					{
						tableRemark: '用户表',
						tableName: 'sys_user',
						tableType: 'parent',
						tableColumn: [
							{
								columnRemark: '姓名',
								columnName: 'name'
							},
							{
								columnRemark: '性别',
								columnName: 'sex'
							}
						]
					},
					{
						tableRemark: '报名信息表',
						tableName: 'sys_signup_info',
						tableType: 'child',
						foreignKey: 'id',
						primaryKey: 'user_id',
						tableColumn: [
							{
								columnRemark: '申请类型',
								columnName: 'apply_type'
							}
						]
					},
					{
						tableRemark: '报名信息扩展表',
						tableName: 'sys_signup_info_ext',
						tableType: 'child',
						foreignKey: 'id',
						primaryKey: 'user_id',
						tableColumn: [
							{
								columnRemark: '申请职位',
								columnName: 'apply_position'
							}
						]
					}
				],
				dictData: [
					{
						id: '1265216211667636226',
						parentId: '0',
						dictValue: 'common_status',
						name: '通用状态',
						children: [
							{
								id: '1265216617500102656',
								parentId: '1265216211667636226',
								dictValue: '0',
								name: '正常',
								children: []
							},
							{
								id: '1265216617500102657',
								parentId: '1265216211667636226',
								dictValue: '1',
								name: '停用',
								children: []
							},
							{
								id: '1265216938389524482',
								parentId: '1265216211667636226',
								dictValue: '2',
								name: '删除',
								children: []
							}
						]
					},
					{
						id: '1265216211667636234',
						parentId: '0',
						dictValue: 'sex',
						name: '性别',
						children: [
							{
								id: '1265216536659087357',
								parentId: '1265216211667636234',
								dictValue: '1',
								name: '男',
								children: []
							},
							{
								id: '1265216536659087358',
								parentId: '1265216211667636234',
								dictValue: '2',
								name: '女',
								children: []
							},
							{
								id: '1265216536659087359',
								parentId: '1265216211667636234',
								dictValue: '3',
								name: '未知',
								children: []
							}
						]
					}
				]
			}
		},
		mounted() {
			const orgTree = [
				{
					id: '1543842934270394368',
					parentId: '0',
					weight: 1,
					name: '小诺科技有限公司',
					children: [
						{
							id: '1543842934270394369',
							parentId: '1543842934270394368',
							weight: 2,
							name: '领导班子'
						},
						{
							id: '1543842934270394370',
							parentId: '1543842934270394368',
							weight: 3,
							name: '工会办公室'
						},
						{
							id: '1543842934270394371',
							parentId: '1543842934270394368',
							weight: 4,
							name: '综合管理部'
						},
						{
							id: '1543842934270394372',
							parentId: '1543842934270394368',
							weight: 5,
							name: '财务资产部'
						},
						{
							id: '1543842934270394373',
							parentId: '1543842934270394368',
							weight: 6,
							name: '人力资源部'
						},
						{
							id: '1543842934270394374',
							parentId: '1543842934270394368',
							weight: 7,
							name: '党群工作部'
						},
						{
							id: '1543842934270394375',
							parentId: '1543842934270394368',
							weight: 8,
							name: '纪检监督部'
						},
						{
							id: '1543842934270394376',
							parentId: '1543842934270394368',
							weight: 9,
							name: '生产技术部'
						},
						{
							id: '1543842934270394377',
							parentId: '1543842934270394368',
							weight: 10,
							name: '计划营销部'
						},
						{
							id: '1543842934270394378',
							parentId: '1543842934270394368',
							weight: 11,
							name: '后勤保卫部'
						},
						{
							id: '1543842934270394379',
							parentId: '1543842934270394368',
							weight: 12,
							name: '西南分公司',
							children: [
								{
									id: '1543842934270394380',
									parentId: '1543842934270394379',
									weight: 13,
									name: '综管部'
								},
								{
									id: '1543842934270394381',
									parentId: '1543842934270394379',
									weight: 14,
									name: '研发部'
								},
								{
									id: '1543842934270394382',
									parentId: '1543842934270394379',
									weight: 15,
									name: '销售部'
								},
								{
									id: '1543842934270394383',
									parentId: '1543842934270394379',
									weight: 16,
									name: '人事部'
								},
								{
									id: '1543842934270394384',
									parentId: '1543842934270394379',
									weight: 17,
									name: '采购部'
								},
								{
									id: '1543842934270394385',
									parentId: '1543842934270394379',
									weight: 18,
									name: '技术部'
								},
								{
									id: '1543842934270394386',
									parentId: '1543842934270394379',
									weight: 19,
									name: '质检部'
								}
							]
						}
					]
				}
			]
			const userList = [
				{
					id: '1543837863788879871',
					account: 'superAdmin',
					name: '超管1',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879873',
					account: 'bizAdmin',
					name: '业管2',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879872',
					account: 'superAdmin',
					name: '超管3',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879874',
					account: 'superAdmin',
					name: '超管4',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879875',
					account: 'superAdmin',
					name: '超管5',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879876',
					account: 'superAdmin',
					name: '超管6',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879877',
					account: 'superAdmin',
					name: '超管7',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837864788879877',
					account: 'superAdmin',
					name: '超管8',
					orgId: '1543842934270494376'
				},
				{
					id: '1543837863788879878',
					account: 'superAdmin',
					name: '超管9',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879879',
					account: 'superAdmin',
					name: '超管10',
					orgId: '1543842934270394376'
				}
			]
			const userList2 = [
				{
					id: '1543837863788879880',
					account: 'superAdmin',
					name: '超管11',
					orgId: '1543842934270394376'
				},
				{
					id: '1543837863788879881',
					account: 'superAdmin',
					name: '超管12',
					orgId: '1543842934270394376'
				}
			]
			const data = { records: userList, total: 12, size: 10, current: 1, pages: 2 }
			const data2 = { records: userList2, total: 12, size: 10, current: 2, pages: 2 }
			setFormDesignConfig({
				getOrgTree: (params) => {
					// 模拟接口请求，获取用户列表，返回Promise
					return Promise.resolve(orgTree)
				},
				getUserPage: (params) => {
					console.log(JSON.stringify(params))
					if (params.current === 2) {
						return Promise.resolve(data2)
					} else {
						// 模拟接口请求，获取用户列表，返回Promise
						return Promise.resolve(data)
					}
				}
			})
		}
	}
</script>
